//
//  ATKit.h
//  FDLive
//
//  Created by CoderLT on 2017/8/1.
//  Copyright © 2017年 FDLive. All rights reserved.
//

#ifndef ATKit_h
#define ATKit_h

#import "UITableViewCell+ATKit.h"
#import "UICollectionViewCell+ATKit.h"
#import "UIView+ATKit.h"
#import "UIView+Badge.h"
#import "UIViewController+ATKit.h"
#import "UITextField+ATKit.h"
#import "UIImage+ATKit.h"
#import "UIFont+ATKit.h"
#import "UIFont+AppTheme.h"
#import "UIColor+AppTheme.h"
#import "NSURL+ATKit.h"
#import "UIDevice+ATKit.h"
#import "NSMutableDictionary+ATKit.h"
#import "NSNumber+ATKit.h"
#import "NSString+ATKit.h"
#import "NSMutableAttributedString+ATKit.h"
#import "MBProgressHUD+ATAdd.h"
#import "ATHightlightButton.h"
#import "NSString+ATKit.h"

/**
 *  系统版本判断
 */
#ifndef kSystemVersion
#define kSystemVersion ([UIDevice currentDevice].systemVersion.doubleValue)
#endif

#ifndef kiOS8Later
#define kiOS8Later (kSystemVersion >= 8)
#endif

#ifndef kiOS9Later
#define kiOS9Later (kSystemVersion >= 9)
#endif

#ifndef kiOS10Later
#define kiOS10Later (kSystemVersion >= 10)
#endif

#ifndef kiOS11Later
#define kiOS11Later (kSystemVersion >= 11)
#endif

#ifndef kIsiPhone4
#define kIsiPhone4     ( fabs((double)[[UIScreen mainScreen] bounds].size.height - ( double )480 ) < DBL_EPSILON )
#endif
#ifndef kIsiPhone5
#define kIsiPhone5     ( fabs((double)[[UIScreen mainScreen] bounds].size.height - ( double )568 ) < DBL_EPSILON )
#endif
#ifndef kIsiPhone6
#define kIsiPhone6     ( fabs((double)[[UIScreen mainScreen] bounds].size.height - ( double )667 ) < DBL_EPSILON )
#endif
#ifndef kIsiPhone6P
#define kIsiPhone6P    ( fabs((double)[[UIScreen mainScreen] bounds].size.height - ( double )736 ) < DBL_EPSILON )
#endif
#ifndef kIsiPhoneX
#define kIsiPhoneX    ( fabs((double)[[UIScreen mainScreen] bounds].size.height - ( double )812 ) < DBL_EPSILON )
#endif
#ifndef kIsiPhone
#define kIsiPhone      ( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone )
#endif
#ifndef kIsiPad
#define kIsiPad        ( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad )
#endif

/**
 *  屏幕适配
 */
#ifndef MAIN_FRAME
#define MAIN_FRAME          ([UIScreen mainScreen].currentBounds)
#endif

#ifndef SCREEN_WIDTH
#define SCREEN_WIDTH        (MIN([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height))
#endif
#ifndef SCREEN_HEIGHT
#define SCREEN_HEIGHT       (MAX([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height))
#endif
#ifndef STATUS_BAR_BAR_ADDING
#define STATUS_BAR_BAR_ADDING       (kIsiPhoneX ? 22 : 0)
#endif
#ifndef STATUS_BAR_HIGHT
#define STATUS_BAR_HIGHT    (kIsiPhoneX ? 44 : 20)
#endif
#ifndef NAVI_BAR_HIGHT
#define NAVI_BAR_HIGHT      (44)
#endif
#ifndef TAB_BAR_ADDING
#define TAB_BAR_ADDING       (kIsiPhoneX ? 34 : 0)
#endif
#ifndef TAB_BAR_HIGHT
#define TAB_BAR_HIGHT       (49 + TAB_BAR_ADDING)
#endif
#ifndef NAVI_HIGHT
#define NAVI_HIGHT          (STATUS_BAR_HIGHT + NAVI_BAR_HIGHT)
#endif
#ifndef SEGMENT_HIGHT
#define SEGMENT_HIGHT       (40)
#endif
#ifndef NAVI_IETM_MARGING
#define NAVI_IETM_MARGING   (([[UIScreen mainScreen] bounds].size.width >= 414 ) ? 20 : 16)
#endif
#ifndef SCALEW
#define SCALEW(value) ((int)((SCREEN_WIDTH * (value) / 375)))
#endif

/**
 *  打印相关
 */
#ifdef DEBUG

#ifndef NSLog
#define NSLog(...) printf("%s [%s:%d] %s\n", [[NSString stringWithFormat:@"%@", [[NSDate date] stringWithFormat:@"HH:mm:ss.SSS"]] UTF8String], [[NSString stringWithFormat:@"%s", __FILE__].lastPathComponent UTF8String] , __LINE__, [[NSString stringWithFormat:__VA_ARGS__] UTF8String]);
#endif

#ifndef DLog
#define DLog(...) NSLog(__VA_ARGS__)
#endif

#ifndef ELog
#define ELog(...) NSLog(__VA_ARGS__)
#endif

#else

#ifndef NSLog
# define NSLog(...)
#endif

#ifndef DLog
#define DLog(...)
#endif

#ifndef ELog
#define ELog(err)
#endif

#endif

/**
 *  多语言
 */
#define ENABLE_LOCALIZED_STRING 0

#ifndef ATLocalizedString
#if defined(ENABLE_LOCALIZED_STRING) && (ENABLE_LOCALIZED_STRING)
#define ATLocalizedString(key, val)  [[ATLanguage sharedInstance] getStringForKey:key table:nil value:(val)]
#define ATLocalizedStringFromTable(key, tbl, val) [[ATLanguage sharedInstance] getStringForKey:key table:tbl value:(val)]
#define ATLocalizedStringFromTableInBundle(key, tbl, bundle, comment) NSLocalizedStringFromTableInBundle(key, tbl, bundle, comment)
#define ATLocalizedStringWithDefaultValue(key, tbl, bundle, val, comment) NSLocalizedStringWithDefaultValue(key, tbl, bundle, val, comment)
#else
#define ATLocalizedString(key, comment) (key)
#define ATLocalizedStringFromTable(key, tbl, comment) (comment)
#define ATLocalizedStringFromTableInBundle(key, tbl, bundle, comment) (comment)
#define ATLocalizedStringWithDefaultValue(key, tbl, bundle, val, comment) (comment)
#endif
#endif

/**
 *  颜色相关
 */
#ifndef RGBA
#define RGBA(r, g, b, a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)]
#endif
#ifndef RGB
#define RGB(r, g, b)     RGBA(r, g, b, 1.0f)
#endif
#define RandomColor      RGB(arc4random_uniform(0xff), arc4random_uniform(0xff), arc4random_uniform(0xff))

/**
 *  添加字典时数据安全
 */
#ifndef SafeDicObj
#define SafeDicObj(obj) ((obj) ? (obj) : @"")
#endif


/**
 转换为字符串
 */
#define ATSTR(str) ({NSString *s = @(#str); if ([s characterAtIndex:0] == '\'' && [s characterAtIndex:s.length-1] == '\'') { s = [s substringWithRange:NSMakeRange(1, s.length - 2)]; }; s;})

#endif /* ATKit_h */
